
package com.lisn.fragmentationupload.utils;

/**
 * 类/接口描述
 *
 */
public class Singleton {

    private static Singleton instance = null;

    /**
     * 方法加锁，防止多线程操作时出现多个实例
     */
    private static synchronized void init() {
        if (instance == null) {
            instance = new Singleton();
        }
    }

    /**
     * 获得当前对象实例
     *
     * @param <T>
     * @return
     */
    public final static <T extends Singleton> T getInstance() {
        if (instance == null) {
            init();
        }
        return (T) instance;
    }

}
